package com.kfm.base.map;

import com.kfm.base.movie.Student;

import java.util.HashMap;

public class Demo01 {

    public static void main(String[] args) {
        /*
          扩展 WeakHashMap 弱引用 WeakReference
         */
//        WeakHashMap<Student, Integer> map = new WeakHashMap<>();
        HashMap<Student, Integer> map = new HashMap<>();

        // 强引用
        Student a = new Student("zhangsan", 20);
        Student b = new Student("lisi", 30);

        map.put(a, 1);
        map.put(b, 2);

        System.out.println(map);


        a = null; // GC

        System.gc();

        System.out.println(map);

    }
}
